package Sort;

import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;

import java.util.Arrays;


public class BubbleSortTest {

    @Test
    public void testBubbleSortWithEmptyArray() {
        int[] arr = {};
        BubbleSort.bubble(arr);
        assertArrayEquals(new int[]{}, arr);
    }

    @Test
    public void testBubbleSortWithSingleElementArray() {
        int[] arr = {1};
        BubbleSort.bubble(arr);
        assertArrayEquals(new int[]{1}, arr);
    }

    @Test
    public void testBubbleSortWithSortedArray() {
        int[] arr = {1, 2, 3, 4, 5};
        BubbleSort.bubble(arr);
        System.out.println(Arrays.toString(arr));
        assertArrayEquals(new int[]{1, 2, 3, 4, 5}, arr);
    }

    @Test
    public void testBubbleSortWithReverseSortedArray() {
        int[] arr = {5, 4, 3, 2, 1};
        BubbleSort.bubble(arr);
        System.out.println(Arrays.toString(arr));
        assertArrayEquals(new int[]{1, 2, 3, 4, 5}, arr);
    }

    @Test
    public void testBubbleSortWithUnsortedArray() {
        int[] arr = {3, 2, 5, 4, 1};
        BubbleSort.bubble(arr);
        assertArrayEquals(new int[]{1, 2, 3, 4, 5}, arr);
    }

    @Test
    public void testBubbleSortWithLargeNumbers() {
        int[] arr = {999, 100, 1, 9999, 1000};
        BubbleSort.bubble(arr);
        assertArrayEquals(new int[]{1, 100, 999, 1000, 9999}, arr);
    }

    @Test
    public void testBubbleSortWithNegativeNumbers() {
        int[] arr = {-3, -1, -2, -5, -4};
        BubbleSort.bubble(arr);
        System.out.println(Arrays.toString(arr));
        assertArrayEquals(new int[]{-5, -4, -3, -2, -1}, arr);
    }
}